import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 1
 * Date: 2023-03-07
 * Time: 9:25
 */
import java.util.Scanner;


import java.util.Scanner;
public class Test {
    public static void main(String[] args) {
        int n = 43;
        System.out.println("奇数位：");
        for (int i = 30; i >= 0 ; i-=2) {
            System.out.print(((n>>i)&1)+ " ");
        }
        System.out.println();
        System.out.println("偶数位：");
        for (int i = 31; i >= 1 ; i-=2) {
            System.out.print(((n>>i)&1)+ " ");
        }
    }

    public static void main18(String[] args) {
        System.out.println("请输入密码：");
        for (int count = 0; count < 3; count++) {
            Scanner scan = new Scanner(System.in);
            String password = scan.nextLine();
            if (password.equals("abcdefg")) {
                System.out.println("密码正确");
                break;
            } else {
                System.out.println("密码错误");
            }
        }
    }

    public static void main17(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int count = 0;
        while (n != 0) {
            n = n & (n - 1);
            count++;
        }
        System.out.println(count);
    }

    public static void main16(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int count = 0;
        while(n != 0) {
            if((n&1) == 1) {
                count++;
            }
            n = n >>> 1;
        }
        System.out.println(count);
    }

    public static void main15(String[] args) {
        int n = 7;
        int count = 0;
        for (int i = 0; i < 32; i++) {
            if(((n>>i)&1) == 1) {
                count++;
            }
        }
        System.out.println(count);
    }

    public static void main14(String[] args) {

        for (int i = 0; i < 999999; i++) {
            int tmp = i;
            int count = 0;
            while(tmp != 0) {
                count++;
                tmp /= 10;
            }
            // tmp==0 count==3
            tmp = i;
            int sum = 0;
            while(tmp != 0) {
                sum += Math.pow((tmp%10),count);
                tmp /= 10;
            }
            if(i == sum) {
                System.out.println(i);
            }
        }
    }

    public static void main13(String[] args) {
        //求两个正整数的最大公约数
        int a = 18;
        int b = 24;
        int c = a%b;
        while(c != 0) {
            a = b;
            b = c;
            c = a % b;
        }
        System.out.println(b);

    }

    public static void main12(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入一个数字:");
        int n = scan.nextInt();
        while(n != 0) {
            System.out.print(n % 10);
            System.out.print(" ");
            n /= 10;
        }
    }
    public static void main11(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入一个数字:");
        int n = scan.nextInt();
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= i; j++) {
                System.out.print(j + "*" + i + "=" + j*i +" ");
            }
            System.out.println();
        }
    }
    public static void main10(String[] args) {
        int count = 0;
        for(int n = 1; n<= 100; n++) {
            if(n % 10 == 9) {
                count++;
            }
            if(n / 10 == 9) {
                count++;
            }
        }
        System.out.println(count);
    }

    public static void main8(String[] args) {
        //打印 1 - 100 之间所有的素数
        for(int n = 1; n <= 100; n++) {
            int i = 2;
            for(; i <= Math.sqrt(n); i++) {
                if(n % i == 0) {
                    break;
                }
            }
            if(i > Math.sqrt(n)) {
                System.out.println(n);
            }
        }
        }

    public static void main9(String[] args) {
        //输出 1000 - 2000 之间所有的闰年
        /*for(int year = 1000; year <= 2000; year++) {
            if(year % 100 != 0) {
                if(year % 4 == 0) {
                    System.out.println(year);
                }
            }
            if(year % 400 == 0) {
                System.out.println(year);
            }
        }*/
        for(int year = 1000; year <= 2000; year++) {
            if(year % 400==0 || year % 4==0 && year % 100!=0) {
                System.out.println(year);
            }
        }
    }
    public static void main6(String[] args) {
        int n = 8;
        int i = 2;
        for(; i <= Math.sqrt(n); i++) {
            if(n % i == 0) {
                System.out.println("不是素数!");
                break;
            }
            i++;
        }
        if(i > Math.sqrt(n)) {
            System.out.println("是素数");
        }
    }

    public static void main5(String[] args) {
        Random random = new Random();
        Scanner scan = new Scanner(System.in);
        int randNum = random.nextInt(100);
        System.out.println("作弊："+randNum);
        System.out.println("请输入你的数字");
        while(true) {
            int a = scan.nextInt();
            if(a > randNum) {
                System.out.println("猜大了");
            }else if(a == randNum) {
                System.out.println("猜对了");
                break;
            }else {
                System.out.println("猜小了");
            }
        }
    }

    public static void main4(String[] args) {
        Scanner scan = new Scanner(System.in);
        /*int a = scan.nextInt();
        System.out.println(a);*/
        /*String name = scan.nextLine();
        System.out.println(name);*/
        double b = scan.nextDouble();
        System.out.println(b);
    }
    public static void main3(String[] args) {
        //计算 1! + 2! + 3! + 4! + 5!
        int i = 1;
        int sum = 0;
        for(i = 1; i <= 5; i++) {
            int j = 1;
            int ret = 1;
            for(j = 1; j <= i; j++) {
               ret *= j;
            }
            sum += ret;
        }
        System.out.println(sum);
        //计算5的阶乘
        /*int i = 1;
        int ret = 1;
        for(i = 1; i <= 5; i++) {
            ret *= i;
        }
        System.out.println(ret);*/
    }
    public static void main2(String[] args) {
        // 找到 100 - 200 中所有 3 的倍数
        int n = 100;
        while(n <= 200) {
            if(n % 3 != 0) {
                n++;
                continue;
            }
            System.out.println(n);
            n++;
        }
        /*int n = 100;
        while(n <= 200) {
            if(n % 3 == 0) {
                System.out.println(n);
            }
            n++;
        }*/

        //找到 100 - 200 中第一个 3 的倍数
        /*int n = 1;
        for(n = 100; n <= 200; n++) {
            if(n % 3 == 0) {
                System.out.println(n);
                break;
            }*/
    }

    //计算 5 的阶乘
    public static void main1(String[] args) {
        /*int n = 1;
        int ret = 1;
        while(n <= 5) {
            ret *= n;
            n++;
        }
        System.out.println(ret);*/
        //计算 1! + 2! + 3! + 4! + 5!
        int sum = 0;
        int i = 1;
        while(i <= 5) {
            int n = 1;
            int ret = 1;
            while(n <= i) {
                ret *= n;
                n++;
            }
            i++;
            sum += ret;
        }
        System.out.println("sum = "+sum);
    }
}
